//
//  LGFollowAdviceRecordController.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/10/7.
//  随访及医嘱记录

#import "LGFollowAdviceRecordController.h"
#import "LGAdviceRecordController.h"
#import "LGConsultRecordController.h"
#import "LGFollowRecordController.h"
@interface LGFollowAdviceRecordController ()
/**  医嘱记录 */
@property (nonatomic , strong)LGAdviceRecordController *adviceVC;
/**  咨询记录 */
@property (nonatomic , strong)LGConsultRecordController *consultVC;
/**  随访记录 */
@property (nonatomic , strong)LGFollowRecordController *followVC;
/**   */
@property (nonatomic , strong)LGNavigationView *navigationView;
/**   */
@property (nonatomic , strong)CAGradientLayer *gradientLayer;
/**   */
@property (nonatomic , strong)NSMutableArray *controllerArray;
/**   */
@property (nonatomic , strong)NSArray *titleArray;
/**   */
@property (nonatomic , strong)NSArray *widthArray;

@end

@implementation LGFollowAdviceRecordController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"随访及医嘱记录";
    [self commonInit];
    self.selectIndex = self.currentInex;
    [self reloadData];
    self.scrollView.backgroundColor = [UIColor clearColor];
}

-(void)backButtonAction{
    if(_backVC){
        [self.navigationController popToViewController:self.backVC animated:YES];
    }else{
        [self.navigationController popViewControllerAnimated:YES];
    }
}

#pragma mark
#pragma mark ====> WMPageControllerDelegate
- (NSInteger)numbersOfChildControllersInPageController:(WMPageController *)pageController {
    return self.titleArray.count;
}

- (NSString *)pageController:(WMPageController *)pageController titleAtIndex:(NSInteger)index {
    return self.titleArray[index];
}

- (UIViewController *)pageController:(WMPageController *)pageController viewControllerAtIndex:(NSInteger)index {
    return self.controllerArray[index];
}

- (CGFloat)menuView:(WMMenuView *)menu widthForItemAtIndex:(NSInteger)index {
    return (Screen_W-20)/5.0;
}

- (CGRect)pageController:(WMPageController *)pageController preferredFrameForMenuView:(WMMenuView *)menuView {
    return CGRectMake(0, topBarHeight, Screen_W, viewPix(44));
}

- (CGRect)pageController:(WMPageController *)pageController preferredFrameForContentView:(WMScrollView *)contentView {
    return CGRectMake(0, topBarHeight+viewPix(44), Screen_W, Screen_H-topBarHeight-viewPix(44));
}

- (void)pageController:(WMPageController *)pageController willEnterViewController:(__kindof UIViewController *)viewController withInfo:(NSDictionary *)info{
//    LGBaseViewController *controller = (LGBaseViewController *)viewController;
//    [controller viewWillAppearAction];
    NSLog(@">>>>>willEnterView>>>%@",viewController.title);
}

- (void)pageController:(WMPageController *)pageController didEnterViewController:(__kindof UIViewController *)viewController withInfo:(NSDictionary *)info{
    NSLog(@">>>>>didEnterView>>>%@",viewController.title);
}

-(void)commonInit{
    self.levelid = (_levelid && _levelid.length>0)?_levelid:@"";
    self.fd_prefersNavigationBarHidden = YES;
    self.view.backgroundColor = [UIColor colorWithString:@"#E5F1FF"];
    [self.view addSubview:self.navigationView];
//    [self.view.layer addSublayer:self.gradientLayer];
    self.titleArray = @[@"医嘱记录",@"咨询记录",@"随访记录"];
    [self addChildViewController:self.adviceVC];
    [self addChildViewController:self.consultVC];
    [self addChildViewController:self.followVC];
    [self.controllerArray addObject:self.adviceVC];
    [self.controllerArray addObject:self.consultVC];
    [self.controllerArray addObject:self.followVC];
    
    self.titleColorNormal = [UIColor colorWithString:@"#666666"];
    self.titleColorSelected = [UIColor colorWithString:@"#4C87FD"];
    self.progressColor = [UIColor colorWithString:@"#3291FF"];
    self.menuViewStyle=WMMenuViewStyleLine;
    self.titleFontName = @"STHeitiTC-Medium";
    self.titleSizeSelected = 16;
    self.titleSizeNormal = 14;
    self.progressWidth = viewPix(13);
    self.progressHeight = 4;
    self.progressViewBottomSpace = 0;
    self.progressViewCornerRadius = 2;
    [self reloadData];
    self.scrollView.backgroundColor = [UIColor clearColor];
}

-(NSMutableArray *)controllerArray{
    if(!_controllerArray){
        _controllerArray = [NSMutableArray array];
    }
    return _controllerArray;
}

-(CAGradientLayer *)gradientLayer{
    if(!_gradientLayer){
        _gradientLayer = [CAGradientLayer layer];
        _gradientLayer.frame = CGRectMake(0,topBarHeight,Screen_W,viewPix(167));
        _gradientLayer.startPoint = CGPointMake(0.5, 0);
        _gradientLayer.endPoint = CGPointMake(0.5, 1.03);
        _gradientLayer.colors = @[(__bridge id)[UIColor colorWithString:@"#E5F3FF"].CGColor, (__bridge id)[UIColor colorWithString:@"#F3F9FE"].CGColor, (__bridge id)[UIColor colorWithString:@"#FEFEFF" alpha:0].CGColor];
        _gradientLayer.locations = @[@(0), @(0.4f), @(1.0f)];
    }
    return _gradientLayer;
}

-(LGNavigationView *)navigationView{
    if(!_navigationView){
        _navigationView = [[LGNavigationView alloc]initWithFrame:CGRectMake(0, 0, Screen_W, topBarHeight)];
        _navigationView.backgroundColor = [UIColor colorWithString:@"#E5F3FF"];
        _navigationView.title = @"随访及医嘱记录";
        [_navigationView.backBtn addTarget:self action:@selector(backButtonAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _navigationView;
}

-(LGAdviceRecordController *)adviceVC{
    if(!_adviceVC){
        _adviceVC = [[LGAdviceRecordController alloc]init];
        _adviceVC.patientid = self.patientid;
        _adviceVC.levelid = self.levelid;
    }
    return _adviceVC;
}

-(LGConsultRecordController *)consultVC{
    if(!_consultVC){
        _consultVC = [[LGConsultRecordController alloc]init];
        _consultVC.patientid = self.patientid;
        _consultVC.levelid = self.levelid;
    }
    return _consultVC;
}

-(LGFollowRecordController *)followVC{
    if(!_followVC){
        _followVC = [[LGFollowRecordController alloc]init];
        _followVC.patientid = self.patientid;
        _followVC.levelid = self.levelid;
    }
    return _followVC;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
